﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CIT.WMS.query
{
    public partial class FrmQueryMetaInfo : Form
    {
        public FrmQueryMetaInfo()
        {
            InitializeComponent();
        }
        BarcodeUtils obj = new BarcodeUtils();
        private void txt_reelid_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (txt_reelid.Text.Length == 0)
                {
                    lab_msg.Text = "请输入料卷.";
                    lab_msg.ForeColor = Color.Red;
                    txt_reelid.SelectAll();
                    txt_reelid.Focus();
                    return;
                }
                BarcodeUtils.BarObject barobj = obj.AnalysisBarcode(Utils.AnalysisSerPath, txt_reelid.Text);
                Utils.uContext.Accountk__BackingField = "mes40";
                DataTable dt = Utils.NMS.QueryDataTable(Utils.uContext, "select * from mdcdatvstorage where reelid='" + barobj.reelId + "'", new CIT.WMS.MESWcf.CmdParameter[0]);
                if (dt.Rows.Count == 0)
                {
                    lab_msg.Text = "料卷不存在.";
                    lab_msg.ForeColor = Color.Red;
                    txt_reelid.SelectAll();
                    txt_reelid.Focus();
                    return;
                }
                txt_datecode.Text = dt.Rows[0]["datecode"].ToString();
                txt_lotno.Text = dt.Rows[0]["batch1"].ToString();
                txt_pn.Text = dt.Rows[0]["partnumber"].ToString();
                txt_po.Text = dt.Rows[0]["pocode"].ToString();
                txt_qty.Text = dt.Rows[0]["qty"].ToString();
                txt_shelfid.Text = dt.Rows[0]["shelfid"].ToString();
                txt_status.Text = dt.Rows[0]["isenable"].ToString() == "0" ? "正常" : "禁用";
                txt_housecode.Text = Utils.HouseInfo(dt.Rows[0]["housecode"].ToString());
                lab_msg.Text = "查询成功.";
                lab_msg.ForeColor = Color.Lime;
                txt_reelid.SelectAll();
                txt_reelid.Focus();
            }
        }


        private void btn_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}